package com.handpay.nocardpay.baselibrary.main.home.presenter;

import android.content.Context;

import com.handpay.nocardpay.baselibrary.commbase.model.IBaseModel;
import com.handpay.nocardpay.baselibrary.commbase.model.bean.BaseErrorInfo;
import com.handpay.nocardpay.baselibrary.commbase.presenter.IBasePresenter;
import com.handpay.nocardpay.baselibrary.main.home.model.LowestAccountTransferAmountModelImpl;
import com.handpay.nocardpay.baselibrary.main.home.model.bean.LowestAccountTransferAmount;
import com.handpay.nocardpay.baselibrary.main.home.view.IHomeView;

import java.util.HashMap;

/**
 * Created by lyang on 2017/8/15.
 */

public class LowestPresenterImpl implements IBasePresenter, IBaseModel.OnRequestFinishedListener<LowestAccountTransferAmount>{

    private LowestAccountTransferAmountModelImpl mLowestAccountTransferAmountModel;
    private IHomeView mHomeView;
    private Context mContext;
//    private LowestAccountTransferAmount mLowestAccountTransferAmount;


    public LowestPresenterImpl(IHomeView homeView, Context context) {
        this.mLowestAccountTransferAmountModel = new LowestAccountTransferAmountModelImpl(context);
        this.mHomeView = homeView;
        mContext = context;
    }



    /**
     * 秒秒通用户登录
     *
     * @param paramers
     * @param clzz
     * @param isShowLoading
     */
    public void getLowestAccountTransferAmount(HashMap<String, Object> paramers, Class<LowestAccountTransferAmount> clzz, boolean isShowLoading) {
        if (mHomeView != null) {
            if (isShowLoading){
                mHomeView.showProgress();
            }
        }
        mLowestAccountTransferAmountModel.request(paramers, clzz, this);
    }

    @Override
    public void onDestory() {

    }

    @Override
    public void onError(BaseErrorInfo baseErrorInfo) {
        if (mHomeView != null) {
            mHomeView.hideProgress();
            mHomeView.showErrorAlert(baseErrorInfo);
        }
    }

    @Override
    public void onSuccess(LowestAccountTransferAmount response) {
        if (mHomeView != null) {
            mHomeView.hideProgress();
            mHomeView.setLowestAccountTransferAmount(response);
//            HPLog.i(HPLog.YL_TAG,"onSuccess:"+mLowestAccountTransferAmount.toString());
        }
    }
}
